<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>计算属性的复杂操作</title>
</head>
<body>
<div id="app">
  <h2>书本总价格：{{totalPrice}}</h2>
</div>
<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      books: [
        {id: 110, name: 'java编程思想', price: 119},
        {id: 111, name: 'java核心技术卷', price: 110},
        {id: 112, name: '深入理解计算机原理', price: 100},
        {id: 113, name: 'javaWeb深入解析', price: 90},
      ]
    },
    computed: {
      totalPrice: function () {
        let result = 0;
        /*for (let i in this.books) {
          result += this.books[i].price;
        }*/

        for (let book of this.books) {
          result += book.price;
        }
        this.books.forEach()
        return result;
      }
    }
  });
</script>
</body>
</html>
